import asyncio


async def eternity():
    await asyncio.sleep(30)
    print("sleep 30")


async def main():
    try:
        await asyncio.wait_for(eternity(), timeout=2)
    except asyncio.TimeoutError:
        print("timeout")


asyncio.run(main())
print("end")